package com.shop.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shop.pojo.wms.Wms_Purchase;
import com.shop.pojo.wms.Wms_Purchase_Detail;
import com.shop.service.Wms_Purchase_Detail_Service;
import com.shop.utils.CaiGouVo;
import com.shop.utils.LayuiUtils;
import com.shop.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 采购需求-李贝贝
 */
@RestController
@RequestMapping("/purchase_detail")
public class Wms_Purchase_Detail_Controller {

    @Autowired
    private Wms_Purchase_Detail_Service wms_purchase_detail_service;



    /**
     * 显示所有采购需求
     * @param page
     * @param limit
     * @param wms_purchase_detail
     * @return
     */
    @GetMapping("/find_All_Purchase_Detail")
    public LayuiUtils<Wms_Purchase_Detail> find_All_Purchase_Detail(Integer page, Integer limit,Wms_Purchase_Detail wms_purchase_detail){
        Page<Wms_Purchase_Detail> pages = new Page<>(page,limit);
        return wms_purchase_detail_service.find_all_pruchase_detail(pages,wms_purchase_detail);
    }

    /**
     * 添加
     * @param wms_purchase_detail
     * @return
     */
    @PostMapping("/insert_Purchase_Detail")
    public R insert_Purchase_Detail(@RequestBody Wms_Purchase_Detail wms_purchase_detail){
        return wms_purchase_detail_service.insert_purchase_detial(wms_purchase_detail);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("/delete_Purchase_Detail")
    public R delete_Purchase_Detail(@RequestParam List<Long> id){
        return wms_purchase_detail_service.delete_purchase_detial(id);
    }

    /**
     * 修改
     * @param wms_purchase_detail
     * @return
     */
    @PutMapping("/update_Purchase_Detail")
    public R update_Purchase_Detail(@RequestBody Wms_Purchase_Detail wms_purchase_detail){
        return wms_purchase_detail_service.update_purchase_detial(wms_purchase_detail);
    }

    /***
     * 查询采购单的状态   查询条件为新建0 已分配1
     * @return
     */
    @GetMapping("/find_admin_Status_Ling_All")
    public List<Wms_Purchase> find_admin_Status_Ling_All(){
        return wms_purchase_detail_service.find_admin_Status_Ling_All();

    }
}
